package com.twittex.model.helpers
{
	import mx.utils.URLUtil;
	
	public class URLParser
	{
		public function URLParser()
		{
		}
		
		public static function urlToATag(url:String):String {
			
			// TODO: Test case needed
			var protocol:String = "((?:http|ftp)://)";
			var urlPart:String = "([a-z0-9-_]+\.[a-z0-9_-]+)";
			var optionalUrlPart:String = "(\.[a-z0-9-_%&\?\/.=]+$)";
			var urlPattern:RegExp = new RegExp(protocol + urlPart + optionalUrlPart, "ig");

			var result:String = url.replace(urlPattern, "<a href='$1$2$3'><u>$1$2$3</u></a>");
			return result;
		}
	}
}